﻿using EF_基础1.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EF_基础1.Configs
{
    public class PigeonConfig : IEntityTypeConfiguration<Pigeon>
    {
        public void Configure(EntityTypeBuilder<Pigeon> builder)
        {
            builder.ToTable("T_Pigeon");
            builder.Property(p => p.Name).IsUnicode().IsRequired().HasMaxLength(100);
            builder.Property(p => p.FeatherColor).IsUnicode().IsRequired().HasMaxLength(100);
            builder.HasOne(p => p.PigeonOwner).WithMany(o => o.Pigeons)
                .HasForeignKey(p => p.PigeonOwnerId)
                .HasConstraintName("PK_PigeonOwnerId")
                .IsRequired();
        }
    }
}
